﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BYS.XiAnComDept.BussLogic;

namespace BYS.XiAnComDept.App.Pages
{
    /// <summary>
    /// Interaction logic for CompanyQuery.xaml
    /// </summary>
    public partial class CompanyQuery : UserControl
    {
        public CompanyQuery()
        {
            InitializeComponent();
        }

        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            using (BllFactory factory = new BllFactory())
            {
                this.DataGridCompanies.ItemsSource = factory.CompanyBll.GetCompanies(this.TextBoxComName.Text.Trim());
            }
        }

        private void DataRow_DoubleClick(object sender, RoutedEventArgs e)
        {
            DataGridRow row = sender as DataGridRow;
            Company com= row.Item as Company;
            NavigationCommands.GoToPage.Execute("/Pages/CompanyEdit.xaml?ComGuid=" + com.ComGuid.ToString(), this);
        }
    }
}
